Get Image Directly

Get Image Directly

You can directly get the image after starting getting stream, or adopts asynchronous mode (thread or timer) to get the image.

Figure 1. Programming Flow of Getting Image Directly
Note:

All the open properties of the camera can be referred to the node sheet "MvCameraNode.xlsx" under the installation directory. The name, definition, data type, value range, and access mode of each node are described in the sheet.

  1. Call MV_CC_EnumDevices to enumerate all devices corresponding to specified transport protocol within subnet.

    The information of found devices is returned in the structure MV_CC_DEVICE_INFO_LIST by pstDevList.

  2. Optional: Call MV_CC_IsDeviceAccessible to check if the specified device is accessible before opening it.
  3. Call MV_CC_CreateHandle to create a device handle.
  4. Optional: Perform one or more of the following operations to get/set different types parameters.
    Option Description

    Get/Set Camera Bool Node Value

    Call MV_CC_GetBoolValue/MV_CC_SetBoolValue

    Get/Set Camera Enum Node Value

    Call MV_CC_GetEnumValue/MV_CC_SetEnumValue

    Get/Set Camera Float Node Value

    Call MV_CC_GetFloatValue/MV_CC_SetFloatValue

    Get/Set Camera Int Node Value

    Call MV_CC_GetIntValueEx/MV_CC_SetIntValueEx

    Get/Set Camera String Node Value

    Call MV_CC_GetStringValue/MV_CC_SetStringValue

    Set Camera Command Node

    Call MV_CC_SetCommandValue

    Note:
    • You can get and set the acquisition mode including single frame acquisition, multi-frame acquisition, and continuous acquisition via the API MV_CC_GetEnumValue (handle, "AcquisitionMode", &stEnumValue) and MV_CC_SetEnumValue (handle, "AcquisitionMode", value).

    • You can set triggering parameters.
      1. Call MV_CC_SetEnumValue (handle, "TriggerMode", value) to set the triggering mode.

      2. If the triggering mode is enabled, call MV_CC_SetEnumValue (handle, "TriggerSource", value) to set the triggering resource. The triggering source includes triggered by hardware and software.

      3. Call MV_CC_GetFloatValue (handle, " TriggerDelay", &stFloatValue) and MV_CC_SetFloatValue (handle, " TriggerDelay", value) to get and set the triggering delay time.

      4. When triggered by software, call MV_CC_SetCommandValue (handle, "TriggerSoftware ") to capture; when triggered by hardware, capture by device local input.

    • You can set the image parameters, including image width/height, pixel format, frame rate, AIO offset, gain, exposure mode, exposure value, brightness, sharpness, saturation, grayscale, white balance, Gamma value, and so on, by calling the following APIs: MV_CC_SetIntValueEx, MV_CC_SetEnumValue, MV_CC_SetFloatValue, MV_CC_SetBoolValue, MV_CC_SetStringValue, MV_CC_SetCommandValue.
  5. Acquire images.
    1. Call MV_CC_StartGrabbing to start getting streams.
      Note:
      • Before starting the acquisition, you can call MV_CC_SetImageNodeNum to set the number of image cache nodes. When the number of obtained images is larger than this number, the earliest image data will be discarded automatically.

      • For original image data, you can call MV_CC_ConvertPixelType to convert the image pixel format, or you can call MV_CC_SaveImageEx2 to convert the image to JPEG or BMP format and save as a file.

    2. Call MV_CC_GetOneFrameTimeout repeatedly in the application layer to get the frame data with specified pixel format.
      Note:

      When getting the frame data, the application program should control the frequency of calling this API according to the frame rate.

  6. Optional: Call MV_CC_DisplayOneFrame to input the window handle and start displaying.
  7. Call MV_CC_StopGrabbing to stop the acquisition or stop displaying.
  8. Call MV_CC_CloseDevice to close the device.
  9. Call MV_CC_DestroyHandle to destroy the handle and release resources.

Get Image Directly

You can directly get the image after starting getting stream, or adopts asynchronous mode (thread or timer) to get the image.

Figure 1. Programming Flow of Getting Image Directly
Note:

All the open properties of the camera can be referred to the node sheet "MvCameraNode.xlsx" under the installation directory. The name, definition, data type, value range, and access mode of each node are described in the sheet.

  1. Call MV_CC_EnumDevices to enumerate all devices corresponding to specified transport protocol within subnet.

    The information of found devices is returned in the structure MV_CC_DEVICE_INFO_LIST by pstDevList.

  2. Optional: Call MV_CC_IsDeviceAccessible to check if the specified device is accessible before opening it.
  3. Call MV_CC_CreateHandle to create a device handle.
  4. Optional: Perform one or more of the following operations to get/set different types parameters.
    Option Description

    Get/Set Camera Bool Node Value

    Call MV_CC_GetBoolValue/MV_CC_SetBoolValue

    Get/Set Camera Enum Node Value

    Call MV_CC_GetEnumValue/MV_CC_SetEnumValue

    Get/Set Camera Float Node Value

    Call MV_CC_GetFloatValue/MV_CC_SetFloatValue

    Get/Set Camera Int Node Value

    Call MV_CC_GetIntValueEx/MV_CC_SetIntValueEx

    Get/Set Camera String Node Value

    Call MV_CC_GetStringValue/MV_CC_SetStringValue

    Set Camera Command Node

    Call MV_CC_SetCommandValue

    Note:
    • You can get and set the acquisition mode including single frame acquisition, multi-frame acquisition, and continuous acquisition via the API MV_CC_GetEnumValue (handle, "AcquisitionMode", &stEnumValue) and MV_CC_SetEnumValue (handle, "AcquisitionMode", value).

    • You can set triggering parameters.
      1. Call MV_CC_SetEnumValue (handle, "TriggerMode", value) to set the triggering mode.

      2. If the triggering mode is enabled, call MV_CC_SetEnumValue (handle, "TriggerSource", value) to set the triggering resource. The triggering source includes triggered by hardware and software.

      3. Call MV_CC_GetFloatValue (handle, " TriggerDelay", &stFloatValue) and MV_CC_SetFloatValue (handle, " TriggerDelay", value) to get and set the triggering delay time.

      4. When triggered by software, call MV_CC_SetCommandValue (handle, "TriggerSoftware ") to capture; when triggered by hardware, capture by device local input.

    • You can set the image parameters, including image width/height, pixel format, frame rate, AIO offset, gain, exposure mode, exposure value, brightness, sharpness, saturation, grayscale, white balance, Gamma value, and so on, by calling the following APIs: MV_CC_SetIntValueEx, MV_CC_SetEnumValue, MV_CC_SetFloatValue, MV_CC_SetBoolValue, MV_CC_SetStringValue, MV_CC_SetCommandValue.
  5. Acquire images.
    1. Call MV_CC_StartGrabbing to start getting streams.
      Note:
      • Before starting the acquisition, you can call MV_CC_SetImageNodeNum to set the number of image cache nodes. When the number of obtained images is larger than this number, the earliest image data will be discarded automatically.

      • For original image data, you can call MV_CC_ConvertPixelType to convert the image pixel format, or you can call MV_CC_SaveImageEx2 to convert the image to JPEG or BMP format and save as a file.

    2. Call MV_CC_GetOneFrameTimeout repeatedly in the application layer to get the frame data with specified pixel format.
      Note:

      When getting the frame data, the application program should control the frequency of calling this API according to the frame rate.

  6. Optional: Call MV_CC_DisplayOneFrame to input the window handle and start displaying.
  7. Call MV_CC_StopGrabbing to stop the acquisition or stop displaying.
  8. Call MV_CC_CloseDevice to close the device.
  9. Call MV_CC_DestroyHandle to destroy the handle and release resources.